package com.netrust.cmsx.admin.modules.sys.utils;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.UnavailableSecurityManagerException;
import org.apache.shiro.session.InvalidSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import com.netrust.cmsx.admin.modules.sys.common.AStatic;
import com.netrust.cmsx.admin.modules.sys.security.Principal;
import com.netrust.cmsx.admin.modules.sys.service.MenuService;
import com.netrust.cmsx.admin.modules.sys.service.SystemService;
import com.netrust.cmsx.admin.modules.sys.service.UserService;
import com.netrust.cmsx.core.persist.TreeUtil;
import com.netrust.cmsx.entity.module.sys.Menu;
import com.netrust.cmsx.entity.module.sys.User;
import com.netrust.cmsx.utils.SpringContextHolder;
import com.netrust.cmsx.utils.collections.CollectionUtils;

public class MenuUtils {
	private static MenuService menuService = SpringContextHolder.getBean(MenuService.class);
	

	
	public static  List<Menu> findMenus(){		
		@SuppressWarnings("unchecked")
		List<Menu> menuList = (List<Menu>)CacheUtils.get(AStatic.Cache.SYS_CACHE,AStatic.Cache.CACHE_MENU_LIST);
		if (CollectionUtils.isEmpty(menuList)){
			menuList=menuService.findByType(AStatic.mtype_menu);
			CacheUtils.put(AStatic.Cache.SYS_CACHE,AStatic.Cache.CACHE_MENU_LIST, menuList);
		};
		return menuList;
	}
	

}
